package cn.xinfei.xdecision.engine.job;

import cn.xinfei.xdecision.model.DecisionReentryApiRequest;
import cn.xinfei.xdecision.service.PulsarService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
//import com.xxl.job.core.context.XxlJobHelper;


@Slf4j
@Service
public class PulsarJob {

    @Autowired
    private PulsarService pulsarService;


    private static final DecisionReentryApiRequest API_REQUEST = new DecisionReentryApiRequest();

    @XxlJob(value = "pulsarRestart", init = "init", destroy = "destroy")
    public ReturnT<String> pulsarRestart(String param) {
        pulsarService.restart(param);
        return ReturnT.SUCCESS;
    }

    @XxlJob(value = "pulsarStop", init = "init", destroy = "destroy")
    public ReturnT<String> pulsarStop(String param) {
        pulsarService.stop(param);
        return ReturnT.SUCCESS;
    }

    @XxlJob(value = "pulsarStats", init = "init", destroy = "destroy")
    public ReturnT<String> pulsarStats(String param) {
        pulsarService.stats(param);
        return ReturnT.SUCCESS;
    }


    public void init() {
        log.info("init");
    }

    public void destroy() {
        log.info("destory");
    }

}
